#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n, k;
	cin>>n>>k;
	string s;
	int ans = 0;
	while(n--)
	{
		cin>>s;
		int num = count(s.begin(), s.end(), k+'0');
		ans = max(ans, num);
	}
	cout<<ans;
	return 0;
}

